Switch import management from Typescript Hero to import-sort #16
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
TypescriptHero only applies it's changes on save, it does not apply changes when `standardize is run via the CLI because there is no way to run TypescriptHero from the command line. These two tools can also have disagreements when it comes to single imports that exceed the maximum line length (one enforces a wrap, one allows the line to exceed). This can cause extra line changes on PRs that muddy the review process and can lead to mistakes or import issues slipping through.
import-sort performs a similar function regarding managing imports but offers a CLI option as well, so it can be run before prettier on CLI functions. This way, the VSCode changes on save sync with the CLI actions during the (updated)
standardize
script. Settings are kept inpackage.json
just like prettier.NOTE: One downside to import-sort is that it does not automatically remove unused imports, so those must be managed manually. Luckily, VSCode now highlights those, and they are not difficult to identify.
I've chosen the
module
sort style for typescript. It groups imports by source module, and separates imports from external libraries and imports from local files with an empty line, which is a nice distinction, in my opinion. There are alternate sort styles available.References:
https://github.com/renke/import-sort